//
//  YTFishpondSNTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/7/30.
//

#import "YTFishpondSNTableViewCell.h"

@interface YTFishpondSNTableViewCell ()

@property (nonatomic ,strong) UIImageView * onecjImg;
@property (nonatomic ,strong) UIImageView * onebackImg;
@property (nonatomic ,strong) UILabel * onenameLab;
@property (nonatomic ,strong) UILabel * onebackLab;

@property (nonatomic ,strong) UIImageView * twecjImg;
@property (nonatomic ,strong) UIImageView * twebackImg;
@property (nonatomic ,strong) UILabel * twenameLab;
@property (nonatomic ,strong) UILabel * twebackLab;

@property (nonatomic ,strong) UIImageView * threecjImg;
@property (nonatomic ,strong) UIImageView * threebackImg;
@property (nonatomic ,strong) UILabel * threenameLab;
@property (nonatomic ,strong) UILabel * threebackLab;

@end

@implementation YTFishpondSNTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.contentView.clipsToBounds = YES;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    
    UIView * backview = [UIView new];
    backview.backgroundColor = KcolorHex(@"#F2F7FF");
    [self.contentView addSubview:backview];
    [backview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(10));
        make.right.offset(kwt(-10));
        make.top.bottom.offset(0);
    }];
    MJWeakSelf
    UIView * oneview = [UIView new];
    oneview.addClickBlock(^{
        [weakSelf oneViewClick];
    });
    [backview addSubview:oneview];
    [oneview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.offset(0);
        make.left.offset(kwt(10));
    }];
    
    UIImageView * onecjImg = kimageView(@"cj_icon");
    self.onecjImg = onecjImg;
    [oneview addSubview:onecjImg];
    [onecjImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(80));
        make.centerX.offset(0);
        make.centerY.offset(kwt(10));
    }];
    
    UILabel * onenameLab = [DTKTool labelWithText:@"--" andFont:kFont(9) andTextColor:KcolorHex(@"#006AF6")];
    onenameLab.backgroundColor = KcolorHex(@"#DEE8FF");
    self.onenameLab = onenameLab;
    onenameLab.textAlignment = NSTextAlignmentCenter;
    [DTKTool YJ:kwt(1) andView:onenameLab];
    [oneview addSubview:onenameLab];
    [onenameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(40));
        make.height.offset(kwt(15));
        make.left.offset(kwt(15));
        make.bottom.offset(kwt(-10));
    }];
    
    UIImageView * onebackImg = kimageView(@"tangkou_bubble");
    onebackImg.addClickBlock(^{
        [weakSelf onealarmClick];
    });
    self.onebackImg = onebackImg;
    [oneview addSubview:onebackImg];
    [onebackImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(30));
        make.top.offset(0);
        make.centerX.offset(0);
    }];
    
    UILabel * onebackLab = [DTKTool labelWithText:@"------" andFont:kFont(10) andTextColor:UIColor.whiteColor];
    onebackLab.numberOfLines = 2;
    self.onebackLab = onebackLab;
    onebackLab.textAlignment = NSTextAlignmentLeft;
    [onebackImg addSubview:onebackLab];
    [onebackLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(85));
        make.center.offset(0);
    }];
    
    
    UIView * tweview = [UIView new];
    tweview.addClickBlock(^{
        [weakSelf tweViewClick];
    });
    [backview addSubview:tweview];
    [tweview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.offset(0);
        make.left.equalTo(oneview.mas_right);
        make.width.equalTo(oneview);
    }];
    
    UIImageView * twecjImg = kimageView(@"cj_icon");
    self.twecjImg = twecjImg;
    [tweview addSubview:twecjImg];
    [twecjImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(80));
        make.centerX.offset(0);
        make.centerY.offset(kwt(10));
    }];

    UILabel * twenameLab = [DTKTool labelWithText:@"--" andFont:kFont(9) andTextColor:KcolorHex(@"#006AF6")];
    twenameLab.backgroundColor = KcolorHex(@"#DEE8FF");
    self.twenameLab = twenameLab;
    twenameLab.textAlignment = NSTextAlignmentCenter;
    [DTKTool YJ:kwt(1) andView:twenameLab];
    [tweview addSubview:twenameLab];
    [twenameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(40));
        make.height.offset(kwt(15));
        make.left.offset(kwt(15));
        make.bottom.offset(kwt(-10));
    }];
    
    UIImageView * twebackImg = kimageView(@"tangkou_bubble");
    
    twebackImg.addClickBlock(^{
        [weakSelf twealarmClick];
    });
    self.twebackImg = twebackImg;
    [tweview addSubview:twebackImg];
    [twebackImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(30));
        make.top.offset(0);
        make.centerX.offset(0);
    }];
    
    UILabel * twebackLab = [DTKTool labelWithText:@"------" andFont:kFont(10) andTextColor:UIColor.whiteColor];
    twebackLab.numberOfLines = 2;
    self.twebackLab = twebackLab;
    twebackLab.textAlignment = NSTextAlignmentLeft;
    [twebackImg addSubview:twebackLab];
    [twebackLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(85));
        make.center.offset(0);
    }];
    
    UIView * threeview = [UIView new];
 
    [backview addSubview:threeview];
    [threeview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.offset(0);
        make.right.offset(kwt(-10));
        make.left.equalTo(tweview.mas_right);
        make.width.equalTo(tweview);
    }];
    UIImageView * threecjImg = kimageView(@"cj_icon");
    self.threecjImg = threecjImg;
    [threeview addSubview:threecjImg];
    [threecjImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(80));
        make.centerX.offset(0);
        make.centerY.offset(kwt(10));
    }];
    threecjImg.addClickBlock(^{
        [weakSelf threeViewClick];
    });
    UILabel * threenameLab = [DTKTool labelWithText:@"--" andFont:kFont(9) andTextColor:KcolorHex(@"#006AF6")];
    threenameLab.backgroundColor = KcolorHex(@"#DEE8FF");
    self.threenameLab = threenameLab;
    threenameLab.textAlignment = NSTextAlignmentCenter;
    [DTKTool YJ:kwt(1) andView:threenameLab];
    [threeview addSubview:threenameLab];
    [threenameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(40));
        make.height.offset(kwt(15));
        make.left.offset(kwt(15));
        make.bottom.offset(kwt(-10));
    }];
    
    UIImageView * threebackImg = kimageView(@"tangkou_bubble");
    threebackImg.addClickBlock(^{
        [weakSelf threealarmClick];
    });
    self.threebackImg = threebackImg;
    [threeview addSubview:threebackImg];
    [threebackImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(100));
        make.height.offset(kwt(30));
        make.top.offset(0);
        make.centerX.offset(0);
    }];
    
    UILabel * threebackLab = [DTKTool labelWithText:@"------" andFont:kFont(10) andTextColor:UIColor.whiteColor];
    threebackLab.numberOfLines = 2;
    self.threebackLab = threebackLab;
    threebackLab.textAlignment = NSTextAlignmentLeft;
    [threebackImg addSubview:threebackLab];
    [threebackLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.offset(kwt(85));
        make.center.offset(0);
    }];
    
}

- (void)oneViewClick{
    if(self.openCJBlock && self.model1){
        self.openCJBlock(self.model1);
    }
}
- (void)tweViewClick{
    if(self.openCJBlock && self.model2){
        self.openCJBlock(self.model2);
    }
}
- (void)threeViewClick{
    if(self.openCJBlock && self.model3){
        self.openCJBlock(self.model3);
    }
}

- (void)onealarmClick{
    
    if(self.addRWBlock && self.model1){
        self.addRWBlock(self.model1);
    }
}
- (void)twealarmClick{
    if(self.addRWBlock && self.model2){
        self.addRWBlock(self.model2);
    }
}
- (void)threealarmClick{
    if(self.addRWBlock && self.model3){
        self.addRWBlock(self.model3);
    }
}

- (void)setModel1:(appPondManageListModel *)model1{
    _model1 = model1;
  
    self.onenameLab.text = model1.name;
    self.onecjImg.image = [UIImage imageNamed:@"cj_icon"];
    if(model1.alarmMessage.length > 0){
        self.onecjImg.image = [UIImage imageNamed:@"yccj_icon"];
        self.onebackImg.hidden = NO;
        self.onebackLab.text = model1.alarmMessage;
    } else {
        self.onebackImg.hidden = YES;
    }
}

- (void)setModel2:(appPondManageListModel *)model2{
    _model2 = model2;
    if(model2){
        self.twecjImg.image = [UIImage imageNamed:@"cj_icon"];
        self.twecjImg.hidden = NO;
        self.twenameLab.hidden = NO;
        self.twenameLab.text = model2.name;
        if(model2.alarmMessage.length > 0){
            self.twebackImg.hidden = NO;
            self.twecjImg.image = [UIImage imageNamed:@"yccj_icon"];
            self.twebackLab.text = model2.alarmMessage;
        } else {
            self.twebackImg.hidden = YES;
        }
    } else {
        self.twecjImg.hidden = YES;
        self.twenameLab.hidden = YES;
        self.twebackImg.hidden = YES;
    }
}

- (void)setModel3:(appPondManageListModel *)model3{
    _model3 = model3;
    if(model3){
        self.threecjImg.image = [UIImage imageNamed:@"cj_icon"];
        self.threecjImg.hidden = NO;
        self.threenameLab.hidden = NO;
        self.threenameLab.text = model3.name;
        if(model3.alarmMessage.length > 0){
            self.threecjImg.image = [UIImage imageNamed:@"yccj_icon"];
            self.threebackImg.hidden = NO;
            self.threebackLab.text = model3.alarmMessage;
        } else {
            self.threebackImg.hidden = YES;
        }
    } else {
        self.threecjImg.hidden = YES;
        self.threenameLab.hidden = YES;
        self.threebackImg.hidden = YES;
    }
  
}


@end
